package com.baizhi.service;

import com.baizhi.dao.AppDao;

import com.baizhi.vo.Category;
import com.baizhi.vo.Video;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
@Transactional
public class AppServiceImpl implements AppService {

    @Autowired
    private AppDao appDao;

    @Transactional(propagation = Propagation.SUPPORTS)
    @Override
    public List<Video> queryVideo() {
        List<Video> videos = appDao.queryVideo();

        return videos;
    }

    @Transactional(propagation = Propagation.SUPPORTS)
    @Override
    public List<Category> queryAllCategory(int levels) {
        List<Category> categories = appDao.queryLevels(levels);
        for (Category category : categories) {
            List<Category> categories1 = appDao.queryByParendId(category.getId());
            category.setCategoryList(categories1);

        }
        return categories;
    }
    //222222222222222222
    //786u67u64h
    //sdibuiibvubyudsyvb
    //h5tghtyhyh76bk678bj57657

}
